import Button from "ui-components/button/button";

/**
 * 具备按下/释放功能的按钮
 */
export default class ButtonCustom extends Button{

    declareVars() {
        super.declareVars();
        this.onPress=null;
        this.pressStart=false;
    }

    pointDown(e) {
        super.pointDown(e);
        this.pressStart=true;
        if(this.props.onPress){
            this.props.onPress(this.tagName,true, this);
        }
        if(this.onPress){
            this.onPress(this.tagName,true, this);
        }
    }

    pointUp(e) {
        super.pointUp(e);
        if(!this.pressStart)return;
        this.pressStart=false;
        if(this.props.onPress){
            this.props.onPress(this.tagName,false, this);
        }
        if(this.onPress){
            this.onPress(this.tagName,false, this);
        }
    }

    pointOut(e) {
        super.pointOut(e);
        if(!this.pressStart)return;
        this.pressStart=false;
        if(this.props.onPress){
            this.props.onPress(this.tagName,false, this);
        }
        if(this.onPress){
            this.onPress(this.tagName,false, this);
        }
    }
}